package com.tongle.frs.common.util.security;

import com.tongle.frs.common.log.HiwiLog;
import com.tongle.frs.common.log.HiwiLogFactory;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class SHAUtil
{
  private static HiwiLog log = HiwiLogFactory.getLogger(SHAUtil.class);

  public static byte[] sha(String input)
  {
    try
    {
      MessageDigest sha = MessageDigest.getInstance("SHA");
      sha.update(input.getBytes());
      return sha.digest();
    } catch (NoSuchAlgorithmException e) {
      log.error("=======SHA加密失败========");
    }
    return null;
  }

  public static byte[] sha1(String input)
  {
    try
    {
      MessageDigest sha = MessageDigest.getInstance("SHA-1");
      sha.update(input.getBytes());
      return sha.digest();
    } catch (NoSuchAlgorithmException e) {
      log.error("=======SHA-1加密失败========");
    }
    return null;
  }
}